package dao

import (
	"zk3zc/inits"
	"zk3zc/model"
)

func AddArt(title string, context string, level int, userId int) (err error) {
	result := &model.Art{
		Title:   title,
		UserId:  userId,
		Context: context,
		Level:   level,
	}
	if err = inits.DB.Create(&result).Error; err != nil {
		return err
	}
	return nil
}

func Login(mobile, password string) (result *model.Art, err error) {
	if err = inits.DB.Where("mobile=? and password = ?", mobile, password).Find(&result).Error; err != nil {
		return nil, err
	}
	return result, nil
}
